var serverUrl;
var scheme = "ws";
var hostname = `websocketserver.com`;
var port = 8010;

// If this is an HTTPS connection, we have to use a secure WebSocket
// connection too, so add another "s" to the scheme.

if (document.location.protocol === "https:") {
    scheme += "s";
    port = 843;
    hostname = document.location.hostname;
}
serverUrl = scheme + "://" + hostname + ":" + port;

connection = new WebSocket(serverUrl, "json");
console.log("***CREATED WEBSOCKET");

connection.onopen = function (evt) {
    console.log("***ONOPEN");
    connection.send('Hello Server !');
};

connection.onmessage = function (evt) {
    console.log("***ONMESSAGE", evt.data);
};

